﻿@namespace MudBlazor.Docs.Examples
@inject ISnackbar SnackbarService

<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@OnClick">Prevent duplicate snackbars</MudButton>

@code {
    private void OnClick()
    {
        // We'll set all three of these snackbars to prevent duplicates and give them
        // all the same key ("mudblazor")
        var config = (SnackbarOptions options) =>
        {
            options.DuplicatesBehavior = SnackbarDuplicatesBehavior.Prevent;
        };

        // Then we try to show all three in quick succession, but only the first pops!
        SnackbarService.Add("This is the only snackbar that will be shown", configure: config, key: "mudblazor");
        SnackbarService.Add(@<span>This one has the same key</span>, configure: config, key: "mudblazor");
        SnackbarService.Add<MudChip<T>>(new Dictionary<string, object>() {
            { "Text", "This one also has the same key" }
        }, configure: config, key: "mudblazor");
    }
}
